<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix ="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<%@ include file="/common/common-css.v2.jsp" %>
		<style>
		#jquery-table td{cursor:pointer !important;word-break: break-all;word-wrap: break-word;}
		.load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
		.load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
		a.check{
			margin-bottom:10px;
		}
		@media (min-width: 768px) and  (max-width: 1200px){
			.backup-text{
				width:100px !important;
			}
		}
		</style>
	</head>
<body  class="no-skin">
<div  class="load_bg" style="display:none;" ></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
<div class="page-content">
<div id="test"></div>
			<div class="page-header" style="margin-bottom:0px;padding-bottom:10px;">
			
				<h1 id="fu_name">
					
				</h1>
			</div>
	<form id="queryForm" >
	<div class="page-content-area">
		<div class="row">
			<div class="col-sm-12">
				<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;">
					<div class="widget-header widget-header-blue widget-header-flat">
						<h4 class="widget-title">选择条件进行查询</h4>

						<div class="widget-toolbar">
							<a href="#" data-action="collapse">
								<i class="ace-icon fa fa-chevron-up"></i>
							</a>
						</div>
					</div>

					<div class=" widget-body">
						<!-- <div class="widget-main" style="padding:12px;border:0px solid #ccc; border-top:none;border-bottom:none;"> -->
									<div class="widget-main clearfix" >
										
								

										<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
											<label class="col-sm-4 control-label" for="form-field-select-1" style="text-align:right;">省份：</label>
											<div class="col-sm-8">
												<s:select id="privonces" name="curprivonce" list="%{paramsMap.privonces}" listKey="id" listValue="name" headerKey="" headerValue="--请选择--" cssClass="form-control" value="%{paramsMap.privonces}">
												</s:select>
											</div>
										</div>

										<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
											<label class="col-sm-4 control-label" for="form-field-select-1" style="text-align:right;">城市：</label>
											<div class="col-sm-8">
												<s:select id="citys" name="citys" list="%{paramsMap.citys}" listKey="id" listValue="name" headerKey="" headerValue="--请选择--" cssClass="form-control" value="%{paramsMap.citys}">
												</s:select>
											</div>
										</div>			
							</div><!-- /.widget-main -->
					</div><!-- /.widget-body -->
				</div><!-- /.widget-box -->
			</div><!-- /.col-sm-12 -->
				<div class="col-md-12 center">
				<div class="clearfix form-actions">
				
					<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="addCity()" id="btn-query">
						<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
						添加
					</button>
					
				  </div>
		   </div>
		</div><!-- /.row -->
		
		<div class="row">
			<div class="col-xs-12">
				<p>⬇️拷贝下面红色的这个到banner编辑的推送城市⬇️</p>
				<div id="citysJson" class="red"></div>
			</div><!-- /.col -->
		</div><!-- /.row -->
			
	</div><!-- /.page-content-area -->
	</form>
</div><!-- /.page-content -->



<%@ include file="/common/common-js.jsp" %>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">

var cityListArray = new Array();


var addCity = function() {
	var privonceData = parseInt($("#privonces").val());
	var chk_value =[];
	var cityData = parseInt($("#citys").val());
	var pushData = null;
	if (cityData == -1) {
		$("#citys option").each(function(){
			pushData = chk_value.push($(this).val());
		});
		pushData = chk_value;
			for (data in pushData) {
				var newcity = pushData[data];
				if(newcity != -1){
				for (cityIndex in cityListArray) {
					var city = cityListArray[cityIndex];
					if (newcity === city) {
						alert("该区域已经选择");
						return;
					}
				}
			}
		}
		for (data in pushData) {
			var newcity = pushData[data];
			if(newcity != -1){
				cityListArray.push(newcity);
			}
		}
	} else {
		pushData = cityData;
		for (cityIndex in cityListArray) {
			var city = cityListArray[cityIndex];
			if (pushData === city) {
				alert("该区域已经选择");
				return;
			}
		}
		cityListArray.push(pushData);
	}
	$("#citysJson").text(JSON.stringify(cityListArray))
}

          
	
//时间控件
jQuery(function($) {

		//类别联动
	    $('#privonces').bind("change", function () {
			var firstCategoryValue = $(this).val();
	    	var citysItem = $("#citys");
	    	citysItem.empty();
	    	citysItem.append("<option value='-1'>--不限--</option>");

	        $.getJSON(ctx + "/mainbanner/getCityList.action", {provinceid : firstCategoryValue}, function (returnObj) {
	           for (var i=0;i < returnObj.citys.length; i++) {
	        	   	var cityData = returnObj.citys[i];
	        	   	citysItem.append("<option value='" + cityData.id + "'>" + cityData.name + "</option>");
	    	   }
	        });
		});
		

	});
	




</script>
		
</body>
</html>